package com.guli.product.config;

import com.guli.common.constant.MqConstant;
import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author zzb
 * @Date 2024/8/13 23:10
 * @Version 1.0
 * @description MQ消息配置类
 */
@Configuration
public class MqConfig {

    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Queue pmsCanalQueue() {
        return new Queue(MqConstant.PMS_CANAL_QUEUE, true);
    }

    @Bean
    public Exchange pmsCanalExchange() {
        return new TopicExchange(MqConstant.PMS_CANAL_EXCHANGE, true, false);
    }

    @Bean
    public Binding pmsCanalBinding() {
        return new Binding(MqConstant.PMS_CANAL_QUEUE, Binding.DestinationType.QUEUE,
                MqConstant.PMS_CANAL_EXCHANGE, MqConstant.CANAL_MQ_PMS_ROUTING, null);
    }

}
